package com.ruoyi.buss.qmcy.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.buss.qmcy.domain.QmcyXykInfo;
import com.ruoyi.buss.qmcy.service.IQmcyXykInfoService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 信用卡信息Controller
 * 
 * @author sxy
 * @date 2021-07-16
 */
@RestController
@RequestMapping("/xyk")
public class QmcyXykInfoController extends BaseController
{
    @Autowired
    private IQmcyXykInfoService qmcyXykInfoService;

    /**
     * 查询信用卡信息列表
     */
    @PreAuthorize(hasPermi = "buss:xyk:list")
    @GetMapping("/list")
    public TableDataInfo list(QmcyXykInfo qmcyXykInfo)
    {
        startPage();
        List<QmcyXykInfo> list = qmcyXykInfoService.selectQmcyXykInfoList(qmcyXykInfo);
        return getDataTable(list);
    }

    /**
     * 导出信用卡信息列表
     */
    @PreAuthorize(hasPermi = "buss:xyk:export")
    @Log(title = "信用卡信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QmcyXykInfo qmcyXykInfo) throws IOException
    {
        List<QmcyXykInfo> list = qmcyXykInfoService.selectQmcyXykInfoList(qmcyXykInfo);
        ExcelUtil<QmcyXykInfo> util = new ExcelUtil<QmcyXykInfo>(QmcyXykInfo.class);
        util.exportExcel(response, list, "信用卡信息数据");
    }

    /**
     * 获取信用卡信息详细信息
     */
    @PreAuthorize(hasPermi = "buss:xyk:query")
    @GetMapping(value = "/{cardNo}")
    public AjaxResult getInfo(@PathVariable("cardNo") String cardNo)
    {
        return AjaxResult.success(qmcyXykInfoService.selectQmcyXykInfoById(cardNo));
    }

    /**
     * 新增信用卡信息
     */
    @PreAuthorize(hasPermi = "buss:xyk:add")
    @Log(title = "信用卡信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QmcyXykInfo qmcyXykInfo)
    {
        return toAjax(qmcyXykInfoService.insertQmcyXykInfo(qmcyXykInfo));
    }

    /**
     * 修改信用卡信息
     */
    @PreAuthorize(hasPermi = "buss:xyk:edit")
    @Log(title = "信用卡信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QmcyXykInfo qmcyXykInfo)
    {
        return toAjax(qmcyXykInfoService.updateQmcyXykInfo(qmcyXykInfo));
    }

    /**
     * 删除信用卡信息
     */
    @PreAuthorize(hasPermi = "buss:xyk:remove")
    @Log(title = "信用卡信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cardNos}")
    public AjaxResult remove(@PathVariable String[] cardNos)
    {
        return toAjax(qmcyXykInfoService.deleteQmcyXykInfoByIds(cardNos));
    }
}
